<template>
  <header class="fxs order">
    <!-- <div class="info"
         v-if="type != 2">
      <p>我的{{Data.commission_name}}</p>
      <span class="fontGilroy">
        <i>¥</i>
        {{Data.total_commissions}}
      </span>
    </div> -->
    <!-- 视频号数据 -->
    <template v-if="sphLive">
      <div class="info2">
      <div class="other fontGilroy">
        <div>
          <span>{{Data.total_commissions}}</span>
          <p>视频号推广订单总金额({{is_crossBorderDz? mSymbol.name:'元'}})</p>
        </div>
        <div>
          <span>{{Data.dhs_total_fee}}</span>
          <p>视频号推广总收益({{is_crossBorderDz? mSymbol.name:'元'}})</p>
        </div>
      </div>
    </div>
    </template>
    <template v-else>

    <!-- 莱特妮丝定制 start -->
    <div class="info2" v-if="ltsn_dz">
      <div class="ltsn fontGilroy">
        <div>
          <span>{{Data.dhs_total_fee}}</span>
          <p>团队订单总金额(元)</p>
        </div>
      </div>
    </div>
    <!-- 莱特妮丝定制 end -->
    <div class="info2" v-else-if="link == 0 && replicate == 0">
      <div :class="Data.hide_next_level_price === 0 ? 'other fontGilroy' : 'fontGilroy'">
        <div>
          <span>{{Data.total_commissions}}</span>
          <p>我的{{Data.commission_name}}(元)</p>
        </div>
        <div v-if="Data.hide_next_level_price === 0">
          <span>{{Data.dhs_total_fee}}</span>
          <p>团队订单总金额(元)</p>
        </div>
      </div>
    </div>
    <nav v-if="!mmxxStatus">
      <!-- 链动订单 -->
      <!-- 链动订单  代理没有平级订单-->
      <!-- 老板身份 -->
      <template v-if="link == 1">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('venderOrder',1)">
          <!-- <p class="num fontGilroy">{{Data.dhs_num}}</p> -->
          <p class="name">下级订单</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[2 == type?'active':'']"
            @click="selectNav('venderOrder',2)">
          <p class="name">平级订单</p>
          <i></i>
        </div>
      </template>
      <!-- 代理身份 -->
      <template v-if="link == 4">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('venderOrder',1)">
          <!-- <p class="num fontGilroy">{{Data.dhs_num}}</p> -->
          <p class="name">下级订单</p>
          <i></i>
        </div>
      </template>
      <!-- 链动成员 老板身份-->
      <template v-else-if="link == 2">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('nextLevelVender',1)">
          <p class="num fontGilroy">{{Data.recommendNum}}</p>
          <p class="name">下级代理</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[2 == type?'active':'']"
            @click="selectNav('nextLevelVender',2)">
          <p class="num fontGilroy">{{Data.levelNum}}</p>
          <p class="name">平级推荐</p>
          <i></i>
        </div>
      </template>
      <!-- 链动成员 代理身份 -->
      <template v-else-if="link == 3">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('nextLevelVender',1)">
          <p class="num fontGilroy">{{Data.superiorNum}}</p>
          <p class="name">上级信息</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[2 == type?'active':'']"
            @click="selectNav('nextLevelVender',2)">
          <p class="num fontGilroy">{{Data.recommendNum}}</p>
          <p class="name">直推代理</p>
          <i></i>
        </div>
      </template>
      <!-- 复制成员 总监身份-->
      <template v-else-if="replicate == 2">
        <div class="nav-item"
            :class="[3 == type?'active':'']"
            @click="selectNav('nextLevelVender',3)">
          <p class="num fontGilroy">{{replicateData[0]}}</p>
          <p class="name">我的点位</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[4 == type?'active':'']"
            @click="selectNav('nextLevelVender',4)">
          <p class="num fontGilroy">{{replicateData[1]}}</p>
          <p class="name">我的直推</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[5 == type?'active':'']"
            @click="selectNav('nextLevelVender',5)">
          <p class="num fontGilroy">{{replicateData[2] || 0}}</p>
          <p class="name">我的平级</p>
          <i></i>
        </div>
      </template>
      <!-- 复制成员 经理身份 -->
      <template v-else-if="replicate == 3">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('nextLevelVender',1)">
          <p class="num fontGilroy">{{replicateData[0]}}</p>
          <p class="name">上级信息</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[2 == type?'active':'']"
            @click="selectNav('nextLevelVender',2)">
          <p class="num fontGilroy">{{replicateData[1]}}</p>
          <p class="name">我的点位</p>
          <i></i>
        </div>
      </template>
      <!-- 复制订单  经理没有平级订单-->
      <!-- 总监身份 -->
      <template v-if="replicate == 1">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('venderOrder',1)">
          <!-- <p class="num fontGilroy">{{Data.dhs_num}}</p> -->
          <p class="name">下级订单</p>
          <i></i>
        </div>
        <div class="nav-item"
            :class="[2 == type?'active':'']"
            @click="selectNav('venderOrder',2)">
          <p class="name">平级订单</p>
          <i></i>
        </div>
      </template>
      <!-- 经理身份 -->
      <template v-if="replicate == 4">
        <div class="nav-item"
            :class="[1 == type?'active':'']"
            @click="selectNav('venderOrder',1)">
          <!-- <p class="num fontGilroy">{{Data.dhs_num}}</p> -->
          <p class="name">下级订单</p>
          <i></i>
        </div>
      </template>
      <!-- 三三复制 end -->
      <template v-else-if="link == 0 && replicate == 0">
      <div class="nav-item"
           :class="[0 == type?'active':'']"
           @click="selectNav('nextLevelVender')">
        <p class="num fontGilroy">{{Data.dhs_num}}</p>
        <p class="name">{{Data.ftitle_dhs_user}}</p>
        <i></i>
      </div>
      <div class="nav-item"
           :class="[1 == type?'active':'']"
           @click="selectNav('nextLevelVenderUser')">
        <p class="num fontGilroy">{{Data.user_num}}</p>
        <p class="name">{{Data.ftitle_dhs_member}}</p>
        <i></i>
      </div>
      <div class="nav-item"
           :class="[2 == type?'active':'']"
           @click="selectNav('venderOrder')">
        <p class="num fontGilroy">{{Data.agency_order_total}}</p>
        <p class="name">{{Data.ftitle_dhs_order}}</p>
        <i></i>
      </div>
      </template>
    </nav>
    <nav v-else>
      <div class="nav-item"
           :class="[0 == type?'active':'']"
           @click="selectNav('nextLevelVender')">
        <p class="num fontGilroy">{{Data.dhs_num}}</p>
        <p class="name">{{Data.ftitle_dhs_user}}</p>
        <i></i>
      </div>
      <div class="nav-item"
           :class="[1 == type?'active':'']"
           @click="selectNav('nextLevelVenderUser')">
        <p class="num fontGilroy">{{Data.user_num}}</p>
        <p class="name">{{Data.ftitle_dhs_member}}</p>
        <i></i>
      </div>
      <div class="nav-item"
           :class="[2 == type?'active':'']"
           @click="selectNav('venderOrder',2)">
        <p class="num fontGilroy">{{Data.agency_order_total_level}}</p>
        <p class="name">带队订单</p>
        <i></i>
      </div>
      <div class="nav-item"
           :class="[3 == type?'active':'']"
           @click="selectNav('venderOrder',3)">
        <p class="num fontGilroy">{{Data.agency_order_total}}</p>
        <p class="name">推广订单</p>
        <i></i>
      </div>
    </nav>
    </template>
  </header>
</template>

<script>
import Vue from 'vue'
import small from '@/smallapp/small.js'
import { openPage } from '@/utils/utils'
export default Vue.extend({
  props: {
    type: Number,
    Data: {
      type: Object
    },
    replicateData: {
      type: Array,
      default: () => {
        return [0, 0]
      }
    },
    link: {
      type: [Number, String],
      default: 0
    },
    replicate: {
      type: [Number, String],
      default: 0
    },
    sphLive: {
      type: [Number, String],
      default: 0
    }
  },
  data() {
    return {
      // 妈妈心选定制
      mmxxStatus: false,
      // 莱特妮丝定制
      ltsn_dz: false,
      sid:'',
      pid:'',
      nextLevelId: undefined // 下级订货商id
    }
  },
  methods: {
    selectNav(path, data) {
      if (this.mmxxStatus) {
        this.$JumpPath(this, path)
        window.sessionStorage.setItem('mmxxStatus', data)
        this.$emit('clickStatus', data)
      } else {
        if (this.$route.query.nextLevelId) {
          this.nextLevelId = this.$route.query.nextLevelId
        }
        //TODO 小程序特殊处理拼接链接跳转，防止路由跳过多次
          this.sid = small.globalData.shopId
          let linkRouter = ''
          this.pid = small.wxCache('global_login_info') ? small.wxCache('global_login_info').uid : '0'
          // console.log('111', this.link)
          if (this.link) {
            let link = 0
            if (this.link == 1 || this.link == 2) {
              link = 2
            } else if (this.link == 3 || this.link == 4) {
              link = 1
            }
            if (this.nextLevelId) {
              linkRouter = window.location.origin + '/mb/user/' + path + '?sid=' + this.sid + '&pid=' + this.pid + '&nextLevelId=' + this.nextLevelId + '&link=' + link + '&type=' + data
            } else {
              linkRouter = window.location.origin + '/mb/user/' + path + '?sid=' + this.sid + '&pid=' + this.pid + '&link=' + link + '&type=' + data
            }
          } else if (this.replicate) {
            let replicate = this.replicate
            if (this.replicate == 1 || this.replicate == 2) {
              replicate = 2
            } else if (this.replicate == 3 || this.replicate == 4) {
              replicate = 1
            }
            this.$JumpPath(this, path, { nextLevelId: this.nextLevelId, replicate, type: data })
          } else {
            if (this.nextLevelId) {
              linkRouter = window.location.origin + '/mb/user/' + path + '?sid=' + this.sid + '&pid=' + this.pid + '&nextLevelId=' + this.nextLevelId
            } else {
              linkRouter = window.location.origin + '/mb/user/' + path + '?sid=' + this.sid + '&pid=' + this.pid
            }
          }
          openPage(linkRouter,1)
      }
    }
  },
  created() {
    const shop = this.$route.query.sid
    // 妈妈心选定制
    const mmxx = this.$_shop('$_mmxx', shop)
    this.mmxxStatus = mmxx
    // 莱特妮丝定制
    const ltsn_dz = this.$_shop('$_ltsn_dz', shop)
    this.ltsn_dz = ltsn_dz
  }
})
</script>

<style lang="scss">
@import "src/styles/variables";
@import "src/styles/mixin";
header {
  position: relative;
  width: 100%;
  .info {
    text-align: center;
    color: $default;
    background: url("https://img.wifenxiao.com/h5-wfx/images/user/fenxiaoGood_bg.png")
      center/cover no-repeat;
    overflow: hidden;
    height: 210px;
    padding-top: 56px;
    box-sizing: border-box;
    span {
      display: block;
      font-size: 50px;
      font-weight: bold;
    }
    p {
      margin-top: 20px;
      font-size: 26px;
      color: #ffd9dd;
    }
  }
  .info2 {
    background: url("https://img.wifenxiao.com/h5-wfx/images/user/fenxiaoGood_bg.png")
      center/cover no-repeat;
    text-align: center;
    margin: 0 auto;
    color: $default;
    overflow: hidden;
    height: 210px;
    padding-top: 56px;
    box-sizing: border-box;
    span {
      display: block;
      font-size: 50px;
      font-weight: bold;
    }
    p {
      margin-top: 20px;
      font-size: 26px;
      color: #ffd9dd;
    }
    .other {
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
      &::before {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: 1px;
        height: 80px;
        background-color: #ff7c86;
      }
      div {
        flex: 1;
      }
    }
    .ltsn {
      display: flex;
      justify-content: center;
      align-items: center;
      position: relative;
    }
  }
  nav {
    width: 100%;
    height: 135px;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    // overflow: hidden;
    .nav-item {
      flex: 1;
      height: 100%;
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;

      p {
        text-align: center;
        &.num {
          font-size: 32px;
          color: #f30c23;
          font-weight: bold;
        }
        &.name {
          font-size: 24px;
          color: #666;
          margin-top: 18px;
        }
      }
      &.active i {
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        height: 6px;
        width: 96px;
        @include gradient(right, rgba(242, 11, 34, 1), rgba(242, 11, 34, 0.2));
      }
      // &::after {
      //   position: absolute;
      //   top: 50%;
      //   right: 0;
      //   width: 0;
      //   height: 30px;
      //   transform: translateY(-50%);
      //   content: "";
      //   border: 0.5px solid #e8e8e8;
      //   // background: black;
      // }
      // &:last-child {
      //   &::after {
      //     border: none;
      //   }
      // }
    }
  }
}
</style>
